Column

Number of Itmes of Each Department of Instacart

Column

Distribution of Order Hour of Day for Each Department

Chart C

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(tidyverse)
library(plotly)
library(p8105.datasets)
library(flexdashboard)
data("instacart")

library(p8105.datasets)

theme_set(theme_minimal() + theme(legend.position = "right"))

options(
  ggplot2.continuous.colour = "viridis",
  ggplot2.continuous.fill = "viridis"
)

scale_colour_discrete = scale_colour_viridis_d
scale_fill_discrete = scale_fill_viridis_d
```

```{r}
data(instacart)
instacart_df = 
  instacart |> 
  select(
    order_id, product_id, order_number, order_hour_of_day, product_name, aisle, department, department_id
  )

```



Column {data-width=650}
-----------------------------------------------------------------------

### Number of Itmes of Each Department of Instacart

```{r}
instacart_df |> 
  group_by(department) |> 
  plot_ly(x = ~department, y = ~order_hour_of_day, color = ~department,
          type = "box", colors = "viridis")
```

Column {data-width=350}
-----------------------------------------------------------------------

### Distribution of Order Hour of Day for Each Department

```{r}
instacart_df |> 
  group_by(department_id, department) |>
  summarize(n_items = n()) |> 
  mutate(
    department = as.factor(department),
    text_label = str_c("Department ID: ", department_id)
    ) |> 
  plot_ly(y =~n_items, x=~reorder(department, +n_items), text =~text_label,
          type = "scatter", mode = "markers", alpha = .5)
```

### Chart C

```{r}

```